#include "eudaq/DataConverterPlugin.hh"
#include "eudaq/Exception.hh"
#include "eudaq/RawDataEvent.hh"
#include "eudaq/Configuration.hh"
#include "eudaq/Logger.hh"

#if USE_LCIO
#  include "IMPL/LCEventImpl.h"
#  include "IMPL/TrackerRawDataImpl.h"
#  include "IMPL/TrackerDataImpl.h"
#  include "IMPL/LCCollectionVec.h"
#  include "IMPL/LCGenericObjectImpl.h"
#  include "UTIL/CellIDEncoder.h"
#  include "lcio.h"
#endif

#if USE_EUTELESCOPE
#  include "EUTELESCOPE.h"
#  include "EUTelMimoTelDetector.h"
#  include "EUTelMimosa18Detector.h"
#  include "EUTelMimosa26Detector.h"
#  include "EUTelSetupDescription.h"
#  include "EUTelEventImpl.h"
#  include "EUTelSparseDataImpl.h"
#  include "EUTelSimpleSparsePixel.h"
#  include "EUTelRunHeaderImpl.h"
using eutelescope::EUTELESCOPE;
#endif

#include <iostream>
#include <ostream>
#include <string>
#include <vector>
#include <memory>
#include <iomanip>
#include <algorithm>

namespace eudaq {
  static const std::string EVENT_TYPE = "MVD";
  static const int dbg = 0; // 0=off, 1=structure, 2=structure+data

  class MVDConverterPlugin : public DataConverterPlugin {
	  typedef std::vector<unsigned char> datavect;
	  typedef std::vector<unsigned char>::const_iterator datait;

  public:
	  virtual void Initialize(const Event & bore, const Configuration & /*c*/) {
			m_boards = from_string(bore.GetTag("BOARDS"), 0);
			m_ids.clear();
			for (unsigned i = 0; i < m_boards; ++i) {
				unsigned id = from_string(bore.GetTag("ID" + to_string(i)), i);
				m_ids.push_back(id);
			}
	  }
	  virtual unsigned GetTriggerID(Event const & ev) const {
	  }
	  virtual bool GetStandardSubEvent(StandardEvent & result, const Event & source) const {
	  }
	  void DecodeFrame(StandardPlane & plane, size_t len, datait it, int frame) const {
	  }
  protected:

    MVDConverterPlugin() : DataConverterPlugin(EVENT_TYPE) {

    }
    unsigned m_boards;
    std::vector<int> m_ids;
    static MVDConverterPlugin m_instance;
  };

  MVDConverterPlugin MVDConverterPlugin::m_instance;

} //namespace eudaq
